package com.javer.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.javer.dao.ArticleDao;
import com.javer.dao.CommentDao;
import com.javer.domain.Article;
import com.javer.domain.Comment;
import com.javer.domain.PageView;

@Service
public class ArticleService {
	@Autowired private ArticleDao articleDao;
	@Autowired private CommentDao commentDao;
	
	public PageView<Article> getPageByType(PageView<Article> pv, String type) {
		pv.setTableName("article");
		return articleDao.getPageByType(pv, type);
	}
	
	public void addArticleComment(Comment comment) {
		commentDao.addComment(comment);
	}
	
	public List<Comment> getHotCommentsByArticle(int id) {
		return commentDao.getHotCommentsById(id, 1);
	}
	
	public void addArticle(Article article) {
		articleDao.addArticle(article);
	}
	
	public List<Article> getNewArticle(int atype, int limit) {
		return articleDao.getNewArticle(atype, limit);
	}
	
	public void updateArticle(Article article) {
		articleDao.updateArticle(article);
	}
	
	public Article getById(int id) {
		return articleDao.getById(id);
	}
	
	public PageView<Article> getByPage(PageView<Article> pv) {
		pv.setTableName("article");
		return articleDao.getByPage(pv);
	}

	
}
